#!/bin/bash
# reference to https://linuxize.com/post/create-a-linux-swap-file/
if [ "$(whoami)" = "root" ] ;then 
	if [ -f /swapfile ] ;then
		swapoff -v /swapfile
		rm /swapfile
	fi
	fallocate -l 16G /swapfile
	chmod 600 /swapfile
	mkswap /swapfile
	swapon /swapfile
	echo "/swapfile swap swap defaults 0 0" >>/etc/fstab
else
	echo "Use 'sudo to run this script!"
fi

